package com.netty.websocket;

import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.nio.NioServerSocketChannel;

/**
 * @author Wang Chen Peng
 * @date 2018/12/24
 * describe:
 */
public class WebSocketService {

    public static void main(String[] args) {

        NioEventLoopGroup bossGroup = new NioEventLoopGroup();
        NioEventLoopGroup wockerGroup = new NioEventLoopGroup();

        try {

            ServerBootstrap bootstrap = new ServerBootstrap();
            bootstrap.group(bossGroup, wockerGroup)
                    .channel(NioServerSocketChannel.class)
                    .childHandler(new WocketServiceInit());

            ChannelFuture channelFuture = bootstrap.bind(8080).sync();
            channelFuture.channel().closeFuture().sync();

        } catch (Exception e) {
            System.out.println("main异常");
            e.printStackTrace();		
        }finally {
            bossGroup.shutdownGracefully();
            wockerGroup.shutdownGracefully();
        }
        
    }


}
